<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Gray发布系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/swiper.min.css">
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/js/swiper.jquery.min.js"></script>
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
</head>
<body>
{% include "public/top.html" %}
<!-- 中部开始 -->
<div class="wrapper">
    {% include "public/left_menu.html" %}
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form" action="/pro-search/">
                <div class="layui-form-pane" style="text-align: left;">
                    <div class="layui-form-item" style="display: inline-block;">

                        <div class="layui-input-inline">
                            <input type="text" name="project_name" value="{{ project_name }}" placeholder="请输入项目名" autocomplete="off"
                                   class="layui-input">
                        </div>
                        <div class="layui-input-inline" style="width:80px">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i
                                    class="layui-icon">&#xe615;</i></button>
                        </div>
                    </div>
                </div>
            </form>
            <span class="x-right" style="line-height:40px">共有数据：{{ list.count }} 条</span>
            <table class="layui-table">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>项目名</th>
                    <th>git地址</th>
                    <th>日志地址</th>
                    <th>构建方式</th>
                    <th>语言</th>
                    <th>打包类型</th>
                    <th>部署机器</th>
                    <th>创建时间</th>
                    <th>当前状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {% for l in list %}
                    <tr>
                    <td>{{ l.id }}</td>
                    <td>
                        <u style="cursor:pointer" onclick="member_show('{{ l.project_name }} 项目说明','/project-desc/','{{ l.id }}','800','300')">
                            {{ l.project_name }}
                        </u>
                    </td>
                    <td>{{ l.git_addr }}</td>
                    <td>{{ l.log_path }}</td>
                    <td>{{ l.build_way }}</td>
                    <td>
                        {% if l.project_lan == 1 %} Java {% endif %}
                        {% if l.project_lan == 2 %} Python {% endif %}
                        {% if l.project_lan == 3 %} Go {% endif %}
                    </td>
                    <td>
                        {% if l.install_type == 1 %} jar {% endif %}
                        {% if l.install_type == 2 %} war {% endif %}
                        {% if l.install_type == 3 %} other {% endif %}
                    </td>
                    <td>
                        {% for oa in opt_all %}
                            {% if l.opt_id == oa.id %} {{ oa.opt_name }} {% endif %}
                        {% endfor %}
                    </td>
                    <td>{{ l.create_at | date:"Y-m-d H:i:s" }}</td>
                    <td class="td-status">
                        <span class="layui-btn layui-btn-normal layui-btn-mini">
                            {% if l.status == 1 %}
                                停用
                            {% else %}
                                启用中
                            {% endif %}
                        </span>
                    </td>
                    <td class="td-manage">
                        <a style="text-decoration:none" onclick="member_stop(this,'10001')" href="javascript:;"
                           title="{% if l.status == 1 %} 启用 {% else %} 停用 {% endif %}">
                            <i class="layui-icon">&#xe601;</i>
                        </a>
                        <a title="删除" href="javascript:;" onclick="member_del(this,'1')" style="text-decoration:none">
                            <i class="layui-icon">&#xe640;</i>
                        </a>
                    </td>
                </tr>
                {% endfor %}



                </tbody>
            </table>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
{% include "public/bottom.html" %}
{% include "public/bg_change.html" %}
<script>


    function member_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }

    function opt_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }

    /*查看*/
    function member_show(title, url, id, w, h) {

        {% comment %}$(function () {
            layui.use('form', function () {
                var form = layui.form();
                //监听提交
                form.on('submit(login)', function (data) {
                    layer.msg(JSON.stringify(data.field), function () {
                        location.href = 'index.html'
                    });
                    return false;
                });
            });
        }){% endcomment %}


        x_admin_show(title, url, w, h);
    }

    /*停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function (index) {
            //发异步把用户状态进行更改
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="layui-icon">&#xe62f;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-disabled layui-btn-mini">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!', {icon: 5, time: 1000});
        });
    }

    /*启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function (index) {
            //发异步把用户状态进行更改
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="layui-icon">&#xe601;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', {icon: 6, time: 1000});
        });
    }

    /*删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }
</script>

</body>
</html>